#include <bits/stdc++.h>
using namespace std;
int T, n, m, L, Vl,aa;
int monitor[100005];
struct{
    int d, v, a, flag;
}car[100005];
int mid[100];
int nolimited = 0, ans = 0;
int check(int i)
{
    int v1 = Vl * Vl;
    int v0 = car[i].v * car[i].v;
    if (car[i].a != 0)
    {
        aa = 2 * car[i].a;
    }
    if (car[i].a >= 0 && car[i].v > Vl)
    {
        mid[0] = car[i].d;
        mid[1] = L;
        car[i].flag = 1;
    }
    else if (car[i].a > 0 && car[i].v <= Vl)
    {
        int s = 0;
        s = (v1 - v0)/aa;
        s += car[i].d;
        if (s < L)
        {
            mid[0] = s + 1;
            mid[1] = L;
            car[i].flag = 1;
        }
        else
        {
            car[i].flag = 0;
        }

    }
    else if (car[i].a < 0 && car[i].v > Vl)
    {
        int s1 = 0;
        s1 = (v1 - v0)/aa;
        s1 += car[i].d;
        if (s1 < L)
        {
            mid[0] = car[i].d;
            mid[1] = s1 - 1;
            car[i].flag = 1;
        }
        else
        {
            mid[0] = car[i].d;
            mid[1] = L;
            car[i].flag = 1;
        }
    }
    else
    {
        car[i].flag = 0;
    }
    return mid[0];
    return mid[1];
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> T;
    while (T--)
    {
        cin >> n >> m >> L >> Vl;
        for (int i = 1; i <= n ;i++)
        {
            cin >> car[i].d >> car[i].v >> car[i].a;
        }
        for (int i = 1; i <= m; i++)
        {
            cin >> monitor[i];
        }
        for (int i = 1; i <= n; i++)
        {
            mid[0] = 0;
            mid[1] = 0;
            check(i);
            for (int j = 1; j <= m; j++)
            {
               if (monitor[j] <= mid[1] && monitor[j] >= mid[0] && car[i].flag == 1)
                {
                    nolimited += 1;
                    break;
                }
            }
        cout << nolimited;
    }
    }
    return 0;
}
